﻿
@{
    //page title
    ViewBag.Title = T("Admin.Configuration.Tax.Categories").Text;
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption level-caption">
                    <i class="fa fa-money"></i>
                    @T("Admin.Configuration.Tax.Categories")
                </div>
                <vc:admin-widget widget-zone="tax_category_list_buttons" additional-data="null" />
            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            <div id="tax-categories-grid"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


    <script>
        $(document).ready(function () {
            $("#tax-categories-grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("Categories", "Tax"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        create: {
                            url: "@Html.Raw(Url.Action("CategoryAdd", "Tax"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        update: {
                            url:"@Html.Raw(Url.Action("CategoryUpdate", "Tax"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        },
                        destroy: {
                            url: "@Html.Raw(Url.Action("CategoryDelete", "Tax"))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors",
                        model: {
                            id: "Id",
                            fields: {
                                Name: { editable: true, type: "string" },
                                DisplayOrder: { editable: true, type: "number" },
                                Id: { editable: false, type: "string" }
                            }
                        }
                    },
                    requestEnd: function (e) {
                        if (e.type == "create" || e.type == "update") {
                            this.read();
                        }
                    },
                    error: function (e) {
                        display_kendoui_grid_error(e);
                        // Cancel the changes
                        this.cancelChanges();
                    },
                    serverPaging: true,
                    serverFiltering: true,
                    serverSorting: true
                },
                pageable: {
                    refresh: true,
                    numeric: false,
                    previousNext: false,
                    info: false
                },
                toolbar: [{ name: "create", text: "@T("Admin.Common.AddNewRecord")" }],
                editable: {
                    confirmation: true,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "Name",
                    title: "@T("Admin.Configuration.Tax.Categories.Fields.Name")",
                    width: 300
                }, {
                    field: "DisplayOrder",
                    title: "@T("Admin.Configuration.Tax.Categories.Fields.DisplayOrder")",
                    //integer format
                    format: "{0:0}",
                    width: 100
                }, {
                    command: [{
                        name: "edit",
                        text: {
                            edit: "@T("Admin.Common.Edit")",
                            update: "@T("Admin.Common.Update")",
                            cancel: "@T("Admin.Common.Cancel")"
                        }
                    }, {
                        name: "destroy",
                        text: "@T("Admin.Common.Delete")"
                    }],
                    width: 200
                }]
            });
        });
    </script>
